 

import request from '@/router/axios'

export function exportExcel(query) {
  return request({
    url: '/stm/swstmarketingticket/export',
    method: 'get',
    params: query,
    responseType: 'arraybuffer'
  })
}

export function delBatch(ids) {
  return request({
    url: '/stm/swstmarketingticket/batchDelete',
    method: 'post',
    data: ids
  })
}

export function fetchList(query) {
  return request({
    url: '/stm/swstmarketingticket/page',
    method: 'get',
    params: query
  })
}

export function addObj(obj) {
  if(typeof obj.marketingTicket.bomCode !== 'string') {
    obj.marketingTicket.bomCode = obj.marketingTicket.bomCode.join(",");
  }
  return request({
    url: '/stm/swstmarketingticket',
    method: 'post',
    data: JSON.parse(JSON.stringify(obj))
  })
}

export function getObj(id) {
  return request({
    url: '/stm/swstmarketingticket/details/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return request({
    url: '/stm/swstmarketingticket/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
  if(typeof obj.marketingTicket.bomCode !== 'string') {
    obj.marketingTicket.bomCode = obj.marketingTicket.bomCode.join(",");
  }
  return request({
    url: '/stm/swstmarketingticket',
    method: 'put',
    data: JSON.parse(JSON.stringify(obj))
  })
}

export function approvalObj(query) {
  return request({
    url: '/stm/swstmarketingticket/approval/status',
    method: 'get',
    params: query
  })
}

export function getNeedConfirmData(obj){
  return request({
    url: '/stm/swstmarketingticket/query/needConfirmData',
    method: 'post',
    data: obj
  })
}

export function confirm(id){
  return request({
    url: '/stm/swstmarketingticket/confirm/' + id,
    method: 'get'
  })
}

//查看营销车票历史记录
export function queryPastRecords(param){
  return request({
    url: '/stm/swstmarketingticket/getLogById/'+param.id,
    method: 'get'
  })
}

//查看营销车票历史记录明细
export function queryPastRecordsDetail(param){
  return request({
    url: '/stm/swstmarketingticket/getLogChildById/'+param.id,
    method: 'get'
  })
}